<?php
namespace app\home\model;

use PullWord\Facade\PullWord;
use think\Model;
class News extends Model
{
    protected $pd = 'id';
    protected $schema = [
        'id'            => 'int',
        'title'         => 'string',
        'content'       => 'string',
        'introduce'     => 'string',
        'thumb'         => 'string',
        'hot_order'     => 'int',
        'addtime'       => 'datetime',
        'updatetime'    => 'datetime',
        'image'         => 'string',
        'hash_str'      => 'string',
        'keywords'      => 'string',
    ];

    public function getAddtimeAttr($value)
    {
        return get_date($value);
    }
    public function getUpdatetimeAttr($value)
    {
        return get_date($value);
    }
    public function getDescAttr($value, $data){
        $desc = $data['title']."【真木网】";
        return $desc ;
    }
    public function getKwAttr($value, $data){
        return Seo::getKeywords();
    }
    public static function getByOrder($order="date", $limit=5)
    {
        $order_option = [
            'date'              =>  'addtime',
            'date_desc'         =>  'addtime desc',   
            'hot'               =>  'hot_order',
            'hot_order_desc'    =>  'hot_order desc'
        ];
        return self::order($order_option[$order])
                    ->where("title is not null or title != ''")
                    ->limit($limit)
                    ->select();
    }
}